package com.example.basicknowledge.RecyclerActivity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;

import com.example.basicknowledge.R;

public class RecyclerActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.recycler_activity);

        String[] arr = {"aaa","bbbb","ccc","bbbb","ccc","bbbb","ccc","bbbb","ccc","bbbb","ccc","bbbb","ccc","bbbb","ccc","bbbb","ccc","bbbb","ccc","bbbb","dddd","bbbb","ccc","bbbb","ccc","bbbb","ccc","bbbb","ccc","bbbb","dddd"};
        ReAdapter adapter = new ReAdapter(arr);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL,false);
        adapter.setTestOnClickListener(new ReAdapter.OnClickListener() {
            @Override
            public void onClick(View view, int position) {
                System.out.println(position);
                Toast.makeText(RecyclerActivity.this,Integer.toString(position),Toast.LENGTH_SHORT).show();
            }
        });

        RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycler_view);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
    }
}
